/*
 * @Descripttion:
 * @LastEditors: xzh
 * @LastEditTime: 2023-10-26 13:45:29
 */

import Dile_APi from "@/api";
import { abnormalDataTypeEnum } from "@/utils/typings/abnormalManage/index.type";
import { object_Inf } from "@/utils/typings/index.type";

/*
 * @Descripttion:异常数据类型工具类
 * @LastEditors: xzh
 * @LastEditTime: 2023-09-23 17:45:52
 */
export default class AbormalDataTypeListUtils {
  /**
   * @Author: xzh
   * @Descripttion: 异常数据类型列
   * @Param:
   */
  static tableColumnMap: object_Inf = {
    //模具异常
    [abnormalDataTypeEnum.moldAbnormal]: [
      {
        field: "moldCode",
        //t('page.moldManageArr.moldArchivesArr.code')
        title: "page.moldManageArr.moldArchivesArr.code",
      },
      {
        field: "moldName",
        //t('page.moldManageArr.moldArchivesArr.name')
        title: "page.moldManageArr.moldArchivesArr.name",
      },
    ],
    //设备异常
    [abnormalDataTypeEnum.equipAbnormal]: [
      {
        field: "equipmentInfoModel.code",
        //t('page.equipManageArr.equipArchivesArr.code')
        title: "page.equipManageArr.equipArchivesArr.code",
        width: 200,
      },
      {
        field: "equipmentInfoModel.name",
        //t('page.equipManageArr.equipArchivesArr.name')
        title: "page.equipManageArr.equipArchivesArr.name",
        width: 150,
      },
      {
        field: "equipmentInfoModel.extJson.positionName",
        //t('page.systemManageArr.position')
        title: "page.systemManageArr.position",
      },
      {
        field: "equipmentInfoModel.extJson.departmentName",
        //t('page.equipManageArr.equipArchivesArr.department')
        title: "page.equipManageArr.equipArchivesArr.department",
        width: 100,
      },
      {
        field: "model.abnormalDate",
        //t('page.abnormalManageArr.abnormalDate')
        title: "page.abnormalManageArr.abnormalDate",
        formatter: "YYYY-MM-DD",
      },
      {
        field: "model.abnormalTime",
        //t('page.abnormalManageArr.abnormalTime')
        title: "page.abnormalManageArr.abnormalTime",
      },
      {
        field: "model.abnormalCategory",
        //t('page.abnormalManageArr.abnormalCategory')
        title: "page.abnormalManageArr.abnormalCategory",
        width: 80,
      },
      {
        field: "model.abnormalInfo",
        //t('page.abnormalManageArr.abnormalInfo')
        title: "page.abnormalManageArr.abnormalInfo",
        width: 200,
      },
      {
        field: "model.abnormalLevel",
        //t('page.abnormalManageArr.abnormalLevel')
        title: "page.abnormalManageArr.abnormalLevel",
      },
      {
        field: "equipmentInfoModel.extJson.managerName",
        //t('page.equipManageArr.equipArchivesArr.manager')
        title: "page.equipManageArr.equipArchivesArr.manager",
        width: 80,
      },
      {
        field: "model.remindInfo",
        //t('page.abnormalManageArr.remindInfo')
        title: "page.abnormalManageArr.remindInfo",
        width: 200,
      },
    ],
    //产出量异常
    [abnormalDataTypeEnum.outputAbnormal]: [
      {
        field: "equipmentCode",
        //t('page.equipManageArr.equipArchivesArr.code')
        title: "page.equipManageArr.equipArchivesArr.code",
      },
      {
        field: "equipmentName",
        //t('page.equipManageArr.equipArchivesArr.name')
        title: "page.equipManageArr.equipArchivesArr.name",
      },
    ],
  };
  /**
   * @Author: xzh
   * @Descripttion:异常数据类型列表数据源
   * @Param:
   * @param {abnormalDataTypeEnum} abormalDataType 异常类型
   * @param {string} keyword 关键字
   */
  static async getAbormalDataTypeList(
    abormalDataType: abnormalDataTypeEnum,
    keyword: string,
    pagination: object_Inf
  ) {
    let data: object_Inf = {};
    switch (abormalDataType) {
      case abnormalDataTypeEnum.moldAbnormal:
        //模具异常
        data = await Dile_APi.getMoldAbnormalList({
          keyword,
        });
        break;
      case abnormalDataTypeEnum.equipAbnormal:
        //设备异常
        data = await Dile_APi.getEquipAbnormalList({
          keyword,
          pagination,
        });
        break;
      case abnormalDataTypeEnum.outputAbnormal:
        //产出量异常
        data = await Dile_APi.getOutputAbnormalList({
          keyword,
        });
        break;
    }
    return data;
  }
}
